在我工作第三個月的時候,夥伴們覺得除錯的方式能不能有所改善,於是有提出 EFK 架構,也就是 Elasticsearch 加 Fluent Bit 和 Kibana。Elasticsearch 簡單使用單節點而已畢竟量還不會到很大,Fluent Bit 是一個滿輕量化的解析器。
在數據來源不段增加下它有以下特性
使用 docker-compose 建置服務,以下是 ES 和 kibana 還有一個 cerebro 它可用來管理 Elasticsearch。
version: '3.6'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION}
container_name: elasticsearch
volumes:
- type: bind
source: ./elasticsearch/config/elasticsearch.yml
target: /usr/share/elasticsearch/config/elasticsearch.yml
read_only: true
- type: volume
source: elasticsearch_pv
target: /usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
restart: unless-stopped
environment:
ES_JAVA_OPTS: "-Xms1024m -Xms1024m"
networks:
- efk
deploy:
resources:
limits:
memory: 2048m
reservations:
memory: 1024m
cerebro:
image: yannart/cerebro
container_name: cerebro
ports:
- "9000:9000"
restart: unless-stopped
networks:
- efk
depends_on:
- elasticsearch
kibana:
image: docker.elastic.co/kibana/kibana:${ELK_VERSION}
container_name: kibana
volumes:
- type: bind
source: ./kibana/config/
target: /usr/share/kibana/config
read_only: true
ports:
- "5601:5601"
restart: unless-stopped
networks:
- efk
depends_on:
- elasticsearch
networks:
efk:
driver: bridge
volumes:
elasticsearch_pv: {}
# ./elasticsearch/config/elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1
discovery.type: single-node
bootstrap.memory_lock: true
# ./kibana/config/kibana.yml
server.port: 5601
server.name: kibana
server.host: "0.0.0.0"
elasticsearch.hosts: [ "http://elasticsearch:9200" ]
Fluent Bit 可以做為機器的代理服務,每建立一台服務就安裝它。如下
version: '3.7'
services:
fluent-bit:
image: fluent/fluent-bit:1.7.0
container_name: fluent-bit
volumes:
- type: bind
source: ./fluent/conf/socket
target: /fluent-bit/etc
read_only: true
# IF use read file
# - type: bind
# source: /var/lib/docker/containers
# target: /fluentd/log/containers
ports:
- 24224:24224
- 24224:24224/udp
- 2020:2020
deploy:
resources:
limits:
cpus: '0.05'
memory: 60M
reservations:
cpus: '0.005'
memory: 10M
明天會介紹一下 Fluentd Bit,之後會帶範例